'use strict';

import timestamp from 'time-stamp'

export default {

  /**
   * 时间格式化
   * @param {*} date 时间对象
   * @param {*} format 格式
   */
  formatDate(date, format = 'YYYY/MM/DD HH:mm:ss') {
    return timestamp(format, date);
  },
  parseMsg(action, payload = {}, metadata = {}) {
    const meta = Object.assign({}, {
      timestamp: Date.now(),
    }, metadata);

    return {
      meta,
      data: {
        action,
        payload,
      },
    };
  },
};
